Ok, I played with this a bit more, and I am having some problems. My goal at this point is just to get the motor holding a position and returning to it if forced away.
- use Write3PH to energize the coil to snap the motor to the closest zero phase position
I would appreciate any input.
#define PWM_CHAN 8 // which pair of PWM channels used
#define ENCODER_CHAN 0 // which encoder we are connected to
#define ENCODER_GAIN 1 // Set to -1 if desired to reverse axis direction
#define AMPLITUDE 100 // Set how hard to drive the coils pwm counts
#define AXIS_CHAN 0 // Axis channel to be used and configured
main()
{
WriteSnapAmp(SNAP0+SNAP_PEAK_CUR_LIMIT0,9); // current limit
WriteSnapAmp(SNAP0+SNAP_PEAK_CUR_LIMIT1,9); // current limit
CHAN *ch = &chan[AXIS_CHAN];
ch->Enable=FALSE; // turn feedback back on
ch->OutputChan0=PWM_CHAN;
ch->InputMode=ENCODER_MODE;
ch->InputChan0=ENCODER_CHAN;
ch->OutputMode=BRUSHLESS_3PH_MODE;
ch->InputGain0=ENCODER_GAIN;
ch->invDistPerCycle = 1.0/60960; // 60.96 mm per electrical cycle according to documentation; 1um encoder
Write3PH(ch,AMPLITUDE,0.0 ); // move the pole to zero position
Delay_sec(1.00); // wait a second
Write3PH(ch0,0,0); // turn off the coil
ch->Position=0; // set current position to Zero
ch->Dest=0; // set current position to Zero
ch->CommutationOffset = 60960/4; // offsetting by 1/4 of a cycle
//ch->Enable=TRUE; // turn feedback back on
}